export const dateFormat = (date)=>{
    let currentDate
    if(date){
        let newDate = new Date(date)
        let year = newDate.getFullYear()  // 年份
        let month = newDate.getMonth() + 1  // 月份，返回值为0-11，所以需要加1
        let day = newDate.getDate()  // 日期 
        month = month < 10 ? '0' + month : month.toString()// 对月份和日期进行补零
        day = day < 10 ? '0' + day : day.toString()
        currentDate = year + "-" + month + "-" + day
    }else{
        currentDate = ""
    }    
    return currentDate
}

export const dateFormatTimeStamp = (date)=>{
    let currentDate
    if(date){
        let newDate = new Date(date)
        let year = newDate.getFullYear()  // 年份
        let month = newDate.getMonth() + 1  // 月份，返回值为0-11，所以需要加1
        let day = newDate.getDate()  // 日期 
        let hour = String(newDate.getHours()).padStart(2, '0')
        let minute = String(newDate.getMinutes()).padStart(2, '0')
        let second = String(newDate.getSeconds()).padStart(2, '0')
        month = month < 10 ? '0' + month : month.toString()// 对月份和日期进行补零
        day = day < 10 ? '0' + day : day.toString()
        currentDate = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second
    }else{
        currentDate = ""
    }    
    return currentDate
}
